package com.threegroup.web.pojo;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.threegroup.web.dto.FlavorESDTO;
import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldType;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;

@Document(indexName = "dish", shards = 5, replicas = 1, createIndex = true)
public class DishES {
    @Id
    @JsonFormat
    private Long id;

    @Field(type = FieldType.Text,analyzer = "ik_max_word")
    @JsonFormat
    private String name;

    @Field(type = FieldType.Long)
    @JsonFormat
    private Long categoryId;
    @Field(type = FieldType.Double)
    @JsonFormat
    private BigDecimal price;
    @Field(type = FieldType.Auto)
    @JsonFormat
    private String code;
    @Field(type = FieldType.Auto)
    @JsonFormat
    private String image;

    @Field(type = FieldType.Text,analyzer = "ik_max_word")
    @JsonFormat
    private String description;

    @Field(type = FieldType.Auto)
    @JsonFormat
    private Integer status;
    @Field(type = FieldType.Auto)
    @JsonFormat
    private Integer sort;
    @Field(type = FieldType.Long)
    @JsonFormat
    private Long creator;
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @Field(type = FieldType.Date_Nanos)
    private Date createDate;
    @Field(type = FieldType.Long)
    @JsonFormat
    private Long updater;
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @Field(type = FieldType.Date_Nanos)
    private Date updateDate;

    @Field(type = FieldType.Auto)
    @JsonFormat
    private Integer isDeleted;
    /**
     * DishFlavorEntity实例
     */

    @JsonFormat
    private List<FlavorESDTO> flavors;
    /**
     *
     */
    @Field(type = FieldType.Keyword)
    @JsonFormat
    private String categoryName;

    public DishES() {
    }

    public DishES(Long id, String name, Long categoryId, BigDecimal price, String code, String image, String description, Integer status, Integer sort, Long creator, Date createDate, Long updater, Date updateDate, Integer isDeleted, List<FlavorESDTO> flavors, String categoryName) {
        this.id = id;
        this.name = name;
        this.categoryId = categoryId;
        this.price = price;
        this.code = code;
        this.image = image;
        this.description = description;
        this.status = status;
        this.sort = sort;
        this.creator = creator;
        this.createDate = createDate;
        this.updater = updater;
        this.updateDate = updateDate;
        this.isDeleted = isDeleted;
        this.flavors = flavors;
        this.categoryName = categoryName;
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Long getCategoryId() {
        return categoryId;
    }

    public void setCategoryId(Long categoryId) {
        this.categoryId = categoryId;
    }

    public BigDecimal getPrice() {
        return price;
    }

    public void setPrice(BigDecimal price) {
        this.price = price;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getImage() {
        return image;
    }

    public void setImage(String image) {
        this.image = image;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public Integer getStatus() {
        return status;
    }

    public void setStatus(Integer status) {
        this.status = status;
    }

    public Integer getSort() {
        return sort;
    }

    public void setSort(Integer sort) {
        this.sort = sort;
    }

    public Long getCreator() {
        return creator;
    }

    public void setCreator(Long creator) {
        this.creator = creator;
    }

    public Date getCreateDate() {
        return createDate;
    }

    public void setCreateDate(Date createDate) {
        this.createDate = createDate;
    }

    public Long getUpdater() {
        return updater;
    }

    public void setUpdater(Long updater) {
        this.updater = updater;
    }

    public Date getUpdateDate() {
        return updateDate;
    }

    public void setUpdateDate(Date updateDate) {
        this.updateDate = updateDate;
    }

    public Integer getIsDeleted() {
        return isDeleted;
    }

    public void setIsDeleted(Integer isDeleted) {
        this.isDeleted = isDeleted;
    }


    public List<FlavorESDTO> getFlavors() {
        return flavors;
    }

    public void setFlavors(List<FlavorESDTO> flavors) {
        this.flavors = flavors;
    }

    public String getCategoryName() {
        return categoryName;
    }

    public void setCategoryName(String categoryName) {
        this.categoryName = categoryName;
    }

    @Override
    public String toString() {
        return "DishES{" +
                "id=" + id +
                ", name='" + name + '\'' +
                ", categoryId=" + categoryId +
                ", price=" + price +
                ", code='" + code + '\'' +
                ", image='" + image + '\'' +
                ", description='" + description + '\'' +
                ", status=" + status +
                ", sort=" + sort +
                ", creator=" + creator +
                ", createDate=" + createDate +
                ", updater=" + updater +
                ", updateDate=" + updateDate +
                ", isDeleted=" + isDeleted +
                ", flavors=" + flavors +
                ", categoryName='" + categoryName + '\'' +
                '}';
    }
}
